﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PartyManagement.Models;
using System.Web.UI.WebControls;
using System.Text;

namespace PartyManagement.Controllers {
    public class HomeController:Controller {



        PartyManagementContext db = new PartyManagementContext();

        void AddInformation( ) {
        //    // Role
        //    //Role role1 = new Role();
        //    //role1.roleName = "Nhân viên căn tin";
        //    //Role role2 = new Role();
        //    //role2.roleName = "Khách hàng";
        //    //db.Roles.Add(role1);
        //    //db.Roles.Add(role2);
        //    //db.SaveChanges();

            // User
           
        //    // Group
            //Group group1 = new Group();
            //group1.groupName = "Nghia_DotNet";
            //group1.userID = 1;
            //Group group2 = new Group();
            //group2.groupName = "Nghia_Java";
            //group2.userID = 1;
            //Group group3 = new Group();
            //group3.groupName = "Nga_DotNet";
            //group3.userID = 2;
            //db.Groups.Add(group1);
            //db.Groups.Add(group2);
            //db.Groups.Add(group3);
            //db.SaveChanges();

          
            //UserInGroup userInGroup1 = new UserInGroup();
            //userInGroup1.userID = 2;
            //userInGroup1.groupID = 28;
            //UserInGroup userInGroup2 = new UserInGroup();
            //userInGroup2.userID = 1;
            //userInGroup2.groupID = 28;
            //UserInGroup userInGroup3 = new UserInGroup();
            //userInGroup3.userID = 9;
            //userInGroup3.groupID = 1;
            UserInGroup userInGroup4 = new UserInGroup();
            userInGroup4.userID = 10;
            userInGroup4.groupID = 1;
            UserInGroup userInGroup5 = new UserInGroup();
            userInGroup5.userID = 4;
            userInGroup5.groupID = 2;
            UserInGroup userInGroup6 = new UserInGroup();
            userInGroup6.userID = 5;
            userInGroup6.groupID = 2;
            UserInGroup userInGroup7 = new UserInGroup();
            userInGroup7.userID = 6;
            userInGroup7.groupID = 2;
            UserInGroup userInGroup8 = new UserInGroup();
            userInGroup8.userID = 6;
            userInGroup8.groupID = 3;
            UserInGroup userInGroup9 = new UserInGroup();
            userInGroup9.userID = 6;
            userInGroup9.groupID = 3;
            UserInGroup userInGroup10 = new UserInGroup();
            userInGroup10.userID = 6;
            userInGroup10.groupID = 3;

            //db.UserInGroups.Add(userInGroup1);
            //db.UserInGroups.Add(userInGroup2);
            //db.UserInGroups.Add(userInGroup3);
            db.UserInGroups.Add(userInGroup4);
            db.UserInGroups.Add(userInGroup5);
            db.UserInGroups.Add(userInGroup6);
            db.UserInGroups.Add(userInGroup7);
            db.UserInGroups.Add(userInGroup8);
            //db.UserInGroups.Add(userInGroup9);
            db.UserInGroups.Add(userInGroup10);

            //// Food Category
            //FoodCategory category1 = new FoodCategory();
            //category1.foodCategoryName = "Sinh tố";
            //FoodCategory category2 = new FoodCategory();
            //category2.foodCategoryName = "Nước ngọt";
            //FoodCategory category3 = new FoodCategory();
            //category3.foodCategoryName = "Kem";
            //db.FoodCategories.Add(category1);
            //db.FoodCategories.Add(category2);
            //db.FoodCategories.Add(category3);
            //db.SaveChanges();

            //// Food
            //Food food1 = new Food();
            //food1.foodName = "Sinh tố bơ";
            //food1.foodCategoryID = 1;
            //food1.isAvailable = true;
            //Food food2 = new Food();
            //food2.foodName = "Sinh tố măng cụt";
            //food1.isAvailable = true;
            //food2.foodCategoryID = 1;
            //Food food3 = new Food();
            //food3.foodName = "Pepsi";
            //food3.isAvailable = true;
            //food3.foodCategoryID = 2;
            //Food food4 = new Food();
            //food4.foodName = "Sting dâu";
            //food4.isAvailable = true;
            //food4.foodCategoryID = 2;
            //Food food5 = new Food();
            //food5.foodName = "Kem sô-cô-la";
            //food5.isAvailable = true;
            //food5.foodCategoryID = 3;
            //Food food6 = new Food();
            //food6.foodName = "Kem đậu xanh";
            //food6.isAvailable = false;
            //food6.foodCategoryID = 3;
            //db.Foods.Add(food1);
            //db.Foods.Add(food2);
            //db.Foods.Add(food3);
            //db.Foods.Add(food4);
            //db.Foods.Add(food5);
            //db.Foods.Add(food6);
            //db.SaveChanges();
            // Menu


            // FoodInMenu


            // Event


            // Attend


            db.SaveChanges();
    
        }

        //
        // GET: /Home/

        public ActionResult Index( ) {
            //AddInformation();

            var list = db.Foods.ToList();

            return View();
        }


        public ActionResult About( ) {
            ViewBag.Message = "Your app description page.";

            return View();
        }


        public ActionResult Contact( ) {
            ViewBag.Message = "Your contact page.";

            return View();
        }


        //
        // GET: /Home/Food
        public ActionResult Foods()
        {
            List<Food> foods = db.Foods.ToList();
            ViewBag.Detail = "";
            return View(foods);
        }

        //[HttpPost]
        //public ActionResult Foods(ListBox lstFoodsChoose)
        //{
            
        //    var items = new StringBuilder();
        //    foreach (ListItem item in lstFoodsChoose.Items)
        //    {
        //        items.Append(string.Format("{0}", item.Value));
        //    }
        //    List<Food> foods = db.Foods.ToList();
        //    ViewBag.Detail = items;
        //    return View(foods);
        //}

        //[HttpPost]
        //public ActionResult Foods(FoodModel foodModel)
        //{

        //    foodModel.FoodList = new MultiSelectList(db.Foods.ToList());
        //    string SelectedFoodName = "";
        //    var foodlistname = foodModel.FoodList.Where(m => foodModel.SelectedFood.Contains(m.Value)).Select(m => m.Text);
        //    foreach (var item in foodlistname)
        //    {
        //        SelectedFoodName += item + ",";
        //    }
        //    ViewBag.Detail = SelectedFoodName;
        //    return View(db.Foods.ToList());
        //}

       
    }
}
